package com.mit.web.view.component.list
{
	import com.mit.web.util.Validator;
	
	import flash.events.FocusEvent;
	import flash.system.IME;
	
	import spark.components.ComboBox;
	
	/**
	 * Supper class of all selfdefined ComboBox!
	 * */
	public class AllowIMEComboBox extends ComboBox
	{
		public function AllowIMEComboBox()
		{
			super();
			this.addEventListener(FocusEvent.FOCUS_IN, focusIn_handler, false, 99);
			this.addEventListener(FocusEvent.FOCUS_OUT, focusOut_Handler, false, 99);
		}

		protected function focusIn_handler(event:FocusEvent):void{
			IME.enabled = true;
			
		}
		
		
		
		protected function focusOut_Handler(event:FocusEvent):void
		{
			var src:ComboBox = event.currentTarget as ComboBox;
			
			if(src.selectedIndex < 0 && !Validator.isNullOrBlank(src.textInput.text)){
				src.errorString = "输入的内容未定义";
				event.preventDefault();		
				src.setFocus();
				src.textInput.selectAll();
				
			}else{
				src.errorString = null;
			}
			
		}
	}
}